﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Web;
using System.Web.Mail;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPEMAILLib;


//using MailMessage = System.Web.Mail.MailMessage;

//using ASPEMAILLib;
//using System.Net.Mail; 
//using System.Web.Mail;

namespace Web
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string strBody = "<br>Chào bạn:<b>";

            //SmtpClient client = new SmtpClient("smtp.gmail.com", 587);

            //client.EnableSsl = true;

            //MailAddress from = new MailAddress("dinhminhduan@gmail.com", "[ Your full name here]");

            //MailAddress to = new MailAddress("dinhminhduan@gmail.com", "Your recepient name");

            //MailMessage message = new MailMessage(from, to);

            //message.Body = "This is a test e-mail message sent using gmail as a relay server ";

            //message.Subject = "Gmail test email with SSL and Credentials";

            ////NetworkCredential myCreds = new NetworkCredential("yourname@gmail.com", "password", "");

            ////client.Credentials = myCreds;
            //client.Send(message);
            
            //System.Net.Mail.SmtpClient smtp = new SmtpClient();
            //System.Net.Mail.MailMessage msg = new MailMessage("dinhminhduan@gmail.com", "dinhminhduan@gmail.com", "tiêu đề", strBody);
            //msg.IsBodyHtml = true;
            //smtp.Host = "smtp.gmail.com";//Sử dụng SMTP của gmail
            //smtp.Send(msg);


            //ASPEMAILLib.MailSender Mail = (MailSender)HttpContext.Current.Server.CreateObject("Persits.MailSender");
            //Mail.Host = "112.78.2.32";
            //Mail.From = "duandm@dealcomm.vn";
            //Mail.Port = 25;
            //Mail.Subject = Mail.EncodeHeader("Test gửi mail", "UTF-8");
            //Mail.AddAddress("dinhminhduan@gmail.com", "");
            //Mail.IsHTML = 1;
            //Mail.CharSet = "UTF-8";
            //Mail.ContentTransferEncoding = "Quoted-Pintable";
            //Mail.Body = strBody;
            //Mail.Send("");    


    //        ASPEMAILLib.MailSender Mail = (MailSender)
    //  HttpContext.Current.Server.CreateObject("Persits.MailSender");
    //        Mail.Host = "mail.dealcom.vn";
    //        Mail.Username = "dinhminhduan@gmail.com";
    //        Mail.Password = "your password";
    ////only required for mail servers which require authentication
    //        Mail.From = "dinhminhduan@gmail.com";
    //Mail.FromName = "Your Name";
    //Mail.AddAddress("dinhminhduan@gmail.com");
    //Mail.Subject = "Subject goes here";

    //Mail.Body = "Message body goes here";
    //        Mail.Queue = 1;
    //Mail.Send(Missing.Value);
    //Mail = null; 

            //MailSender objMail = new MailSender();

            //// Set SMTP server address
            //objMail.Host = "localhost";

            //// Sender's address
            //objMail.From = "dinhminhduan@gmail.com";

            //// Recipient's address
            //objMail.AddAddress("dinhminhduan@gmail.com");

            //// Subject
            //objMail.Subject = objMail.EncodeHeader("Tiêu đề", "UTF-8");

            //// Body
            //objMail.Body = "Nội dung";

            //// To handle unicode correctly
            //objMail.CharSet = "UTF-8";
            //objMail.ContentTransferEncoding = "Quoted-Printable";

            //objMail.Send();
            //for (int i = 0; i <= 2; i++)
            //{
            //    MyUtility.MySendEmail.SendEmail_Google("duandm@dealcom.vn", "123456789", "tuandn@i-com.vn",
            //                                           "Chào mừng bạn đến với abc", "noi dung", MailFormat.Html, "");
            //}

            //-----------su dung sytem.web.mail

            //MailMessage mail = new MailMessage();
            //mail.To = "duandm@dealcom.vn";
            //mail.From = "tuandn@i-com.vn";
            //mail.BodyFormat = MailFormat.Html;
            //mail.Subject = "Testing Email";
            //mail.Body = "LET ME KNOW IF YOU GET THIS";
            //SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
            //SmtpMail.Send(mail);


            MailMessage oMail = new System.Web.Mail.MailMessage();
            oMail.From = "duandm@dealcom.vn";
            oMail.To = "dinhminhduan@gmail.com";
            oMail.Subject = "Test email subject";
            oMail.BodyFormat = MailFormat.Html; // enumeration
            oMail.Priority = MailPriority.High; // enumeration
            oMail.Body = "Sent at: " + DateTime.Now;
            SmtpMail.SmtpServer = "localhost";
            SmtpMail.Send(oMail);
            oMail = null; // free up resources

            //-------------sytem.net.mail
            //create the mail message
            //MailMessage mail = new MailMessage();

            ////set the addresses
            //mail.From = new MailAddress("duandm@dealcom.vn");
            //mail.To.Add("dinhminhduan@gmail.com");

            ////set the content
            //mail.Subject = "This is an email";
            //mail.Body = "this is the body content of the email.";

            ////send the message
            //SmtpClient smtp = new SmtpClient("127.0.0.1");

            ////to authenticate we set the username and password properites on the SmtpClient
            //smtp.Credentials = new NetworkCredential("username", "secret");
            //smtp.Send(mail);



        }
    }
}